<template>
  <div class="notice">
    <ArtList ref="noticeList" :dataList="noticeList" @down-cb="downCb" @up-cb="upCb"/>
  </div>
</template>

<script>
import ArtList from '@/components/art-list'

export default {
  name: "notice",
  components: {
    ArtList
  },
  data() {
    return {
      noticeList: [] //列表数据
    }
  },
  methods: {
    async downCb(mescroll) {
      try {
        const res = await this.getList(1, 10)
        this.noticeList = res.data
        mescroll.endSuccess()
      } catch (e) {
        mescroll.endErr()
      }

    },
    async upCb({num, size}, mescroll) {
      // console.log(num)
      try {
        const res = await this.getList(num, size)
        if (res.code === 1) {
          this.noticeList = this.noticeList.concat(res.data)
          mescroll.endBySize(this.noticeList.length, res.count)
        }
      } catch (e) {
        mescroll.endErr()
      }
    },
    getList(page, limit) {
      return this.$get('/problemArea/list', {
        page,
        limit,
        type: 50,
        status: 10
      })
    }
  },
  async mounted() {
    this.$refs['noticeList'].initScroll()
  },
}
</script>

<style lang="less" scoped>
.notice {
  position: relative;
  flex: 1;
}
</style>
